<template>
  <div class="login">
    <div class="app_icon">
      <span><i class="iconfont icon-xingxi"></i></span>
    </div>
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="_username"
        label="用户名"
        placeholder="用户名"
      />
      <van-field
        v-model="password"
        type="password"
        name="_password"
        label="密码"
        placeholder="密码"
      />
      <div style="margin: 16px">
        <van-button
          class="login_btn"
          round
          block
          type="info"
          native-type="submit"
          >提交</van-button
        >
      </div>
    </van-form>
    <span class="youke" @click="$router.back()">游客模式</span>
  </div>
</template>

<script>
import { Toast } from "vant";
export default {
  data() {
    return {
      username: "元气少女蔡徐坤",
      password: "123456",
    };
  },
  methods: {
    onSubmit(values) {
      if (values._username == "" || values._password == "") {
        Toast("请完善信息");
      } else if (values._username !== "元气少女蔡徐坤") {
        Toast("用户名或者密码错误");
      } else if (values._password !== "123456") {
        Toast("用户名或者密码错误");
      }else {
        this.$router.push({name:"my",query:{username:this.username}})
      }
    },
  },
};
</script>

<style lang="less">
.login {
  width: 100%;
  height: 100%;
  position: relative;
  .app_icon {
    height: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    span {
      i {
        font-size: 160px;
        color: rgb(78, 78, 247);
      }
    }
  }
  .van-form {
    width: 100%;
    height: 164px;
  }
  .youke {
    font-size: 12px;
    color: #ccc;
    position: absolute;
    right: 20px;
    top: 75%;
  }
}
</style>